#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：20.使用匿名函数.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-10-09 10:32
'''

stu_info = [
    {'name':'双双', 'age':18},
    {'name':'安娜', 'age':20},
    {'name':'南枫', 'age':16},
    {'name':'王五', 'age':50},
    {'name':'张三', 'age':14},
]

print(f'排序前：{stu_info}')

# stu_info.sort(key=lambda x:x['age'])
#
# print(f'排序后：{stu_info}')


def sort_by_age(stu):
    return stu['age']

new_list = sorted(stu_info, key=sort_by_age)

print(f'排序后：{new_list}')

